/*package com.ikkong.shine.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.redis.Cache;
import com.jfinal.plugin.redis.Redis;
import com.jfinal.plugin.redis.RedisPlugin;

public class GetDataSourceRedisController {

	static int m=0;//此变量是为了切换数据源  
	public static void main(String[] args) {  
	RedisPlugin rp = new RedisPlugin("cmo", "127.0.0.1");  
	rp.start();  
	Cache redis=Redis.use();  
	if(m==0){  
	String jdbcUrl = "jdbc:mysql://localhost:3306/shinetriage?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull";  
	DruidPlugin druidPlugin = new DruidPlugin(jdbcUrl,"root", "shinestb");  
	druidPlugin.start();  
	ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);  
	arp.start();  
	  
	List<Record> list=Db.find("select doctor_id,login_id,name,department from doctor");  
	for(Record r:list){  
	redis.set(r.get("doctor_id"), r.get("login_id"));  
	System.err.println(r.get("login_id")+"===>"+ r.get("login_id"));  
	}  
	  
	String sql="select * from doctor";  
	List<Record> rules=Db.find(sql);  
	for(Record r:rules){  
	Map<Object, Object> rule = new HashMap<Object,Object>();   
	rule.put("login_id", r.get("login_id"));  
	rule.put("name", r.get("name"));  
	rule.put("department", r.get("department"));  
	redis.hset("R_"+r.getStr("doctor_id")+"_"+r.getInt("doctor_id"), r.get("doctor_id"), rule);  
	System.err.println("R_"+r.getStr("doctor_id")+"_"+r.getInt("doctor_id")+"---"+r.get("doctor_id")+"--"+rule);  
	}  
	arp.stop();  
	m=1;  
	}  
	   //切换数据源  
	if(m==1){  
	String jdbcUrlHal = "jdbc:mysql://localhost:3306/xc-cool-hal?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull";  
	DruidPlugin druidPluginhal = new DruidPlugin(jdbcUrlHal,"root", "");  
	druidPluginhal.start();  
	ActiveRecordPlugin arphal = new ActiveRecordPlugin(druidPluginhal);  
	arphal.start();  
	  
	List<Record> channel=Db.find("select deviceId,channelId,status from xc_cool_rds_channel");  
	for(Record r:channel){  
	redis.set("C_"+r.getStr("deviceId")+"_"+r.getInt("channelId"), r.get("status"));  
	System.err.println("C_"+r.getStr("deviceId")+"_"+r.getInt("channelId")+"===>"+ r.get("status"));  
	}  
	m=3;  
	arphal.stop();  
	}  
	} 
}
*/